package main

import "fmt"

//#link: https://leetcode-cn.com/problems/er-jin-zhi-zhong-1de-ge-shu-lcof/
func main() {
	num := uint32(9)
	fmt.Println(hammingWeight(num))
}

func hammingWeight(num uint32) int {
	result := 0
	for i := 31; i >= 0; i-- {
		if num>>i&1 != 0 {
			result++
		}
	}
	return result
}
